#include <iostream>

#include <cstdlib>
#include <ctime>

#include <boost/foreach.hpp>
#define feach BOOST_FOREACH

#include "greedy.hh"

const uint MAX_TRIES = 10;

int main ( int argc, char** argv ) {
  if ( argc != 2 ) return 0;

  srand ( time(NULL) );

  Dataset d = readDataSet ( string(argv[1]) );

#ifdef BENCHMARK
  startTimer();
#endif
  vector < BTS* > bestSolution, r;
  uint bestIncome = 0;
  for ( uint i = 0; i < MAX_TRIES; ++i ) {
    r = greedy ( d );
  
    uint currentIncome = 0;
    feach ( BTS* b, r ) currentIncome += b->incomes;

    if ( currentIncome > bestIncome ) {
      bestSolution.assign ( r.begin(), r.end() );
      bestIncome = currentIncome;
    }
  }
#ifdef BENCHMARK
  stopTimer();
#else
  displaySolution ( d, bestSolution );
#endif

  return 0;
}
